<body>
    <form id="my-form">
        <div id="tools" class="datagrid-toolbar">
            <input type="hidden" name="type" id="type" value="8">
            <a id="subBtn" name="subOk" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-save"
                plain="true"><span class="l-btn-left"><span
                        class="l-btn-text icon-save l-btn-icon-left">保存</span></span></a>
            <a id="closeBtn" name="backOk" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-close"
                plain="true"><span class="l-btn-left"><span
                        class="l-btn-text icon-close l-btn-icon-left">关闭</span></span></a>
        </div>
        <p id="errorMsg" style="color:red;margin-top:5px;"></p>
        <table class="formTable">
            <tbody>
                <tr>
                    <td class="tdc1" style="width:150px;">
                        用车人：
                    </td>
                    <td>
                        <input type="text" name="applyUserName" id="applyUserName" data-options="required:true"
                            class="easyui-validatebox texfind validatebox-text" readonly="">
                        <input type="hidden" name="applyUserId" id="applyUserId">
                        <a class="easyui-linkbutton l-btn l-btn-plain" id="clear0" iconcls="icon-undo" plain="true"
                            onclick="clearCheck('applyUserName,applyUserId');"><span class="l-btn-left"><span
                                    class="l-btn-text icon-undo l-btn-icon-left">清除</span></span></a>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        部门经理：
                    </td>
                    <td>
                        <input type="text" name="deptmanagername" id="deptmanagername"
                            class="easyui-validatebox texfind validatebox-text" readonly="">
                        <input type="hidden" name="deptmanagerid" id="deptmanagerid">
                        <a class="easyui-linkbutton l-btn l-btn-plain" id="clear1" iconcls="icon-undo" plain="true"
                            onclick="clearCheck('deptmanagername,deptmanagerid');"><span class="l-btn-left"><span
                                    class="l-btn-text icon-undo l-btn-icon-left">清除</span></span></a>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        目的地：
                    </td>
                    <td>
                        <input type="text" name="destination" id="destination" data-options="required:true"
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        用车时间：
                    </td>
                    <td>
                        <input type="text" name="startTime" id="startTime" readonly="readonly"
                            class="easyui-validatebox Wdate validatebox-text"
                            onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endTime\')}'})"
                            style="width:180px;" data-options="required:true">至
                        <input type="text" name="endTime" id="endTime" readonly="readonly"
                            class="easyui-validatebox Wdate validatebox-text"
                            onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startTime\')}'})"
                            style="width:180px;" data-options="required:true">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        用车事由：
                    </td>
                    <td>
                        <textarea name="reasons" id="reasons" style="width:732px;height:100px"></textarea>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>


    <script>
        initSelect(1);//初始化选人框；1：默认根据部门

        $("#applyUserName").click(function () {
            showSelect('applyUserName,applyUserId', 'text,id', '');
        });

        $("#deptmanagername").click(function () {
            showSelect('deptmanagername,deptmanagerid', 'text,id', '');
        });

        function checkFormMe(form) {

            return $('#my-form').form('validate');
        }

        var type = $.getUrlParam("type");

        $("#type").val(type);

        var p_id = $.getUrlParam("id");

        var BaseModel = Backbone.Model.extend({ urlRoot: contextPath + 'manager/carRegistration' });
        var baseModel;

        if (p_id == null) {
            baseModel = new BaseModel();
        } else {
            baseModel = new BaseModel({ id: p_id, i: new Date().getTime() });
        }
        var baseView = new BaseView({ el: $("#my-form"), model: baseModel });

        function success(model, response, options) {
            var data = model.get("handleMsg");
            $.messager.alert('提示', model.get("handleMsg").message, 'info', function (rt) {
                if (data.status == 1) {
                    //图层解锁
                    //$("#myForm").unblock();
                    var subtitle = encodeURI(encodeURI($.getUrlParam("subtitle")));
                    window.parent.frames["" + $.getUrlParam("_pfrid")].location.reload();
                    window.location.href = contextPath + "system/qdzxapproval/approval/carregistration_edit.html?type=" + type + "&processid=" + model.get("id") + "&_pfrid=" + $.getUrlParam("_pfrid") + "&_frid=" + $.getUrlParam("_frid") + "&subtitle=" + subtitle;
                } else {
                    $("#errorMsg").html(data.message);
                    //图层解锁
                    //$("#myForm").unblock();
                }
            });
        }
    </script>
    <div class="panel window" style="display: none; width: 450px; left: 433px; top: 25px;">
        <div class="panel-header panel-header-noborder window-header" style="width: 450px;">
            <div class="panel-title panel-with-icon">根据部门选择</div>
            <div class="panel-icon icon-manager"></div>
            <div class="panel-tool"><a class="panel-tool-collapse" href="javascript:void(0)"></a><a
                    class="panel-tool-close" href="javascript:void(0)"></a></div>
        </div>
        <div id="selectMan" class="easyui-window panel-body panel-body-noborder window-body" title=""
            data-options="closed:true,modal:true,iconCls:'icon-manager',minimizable:false,maximizable:false"
            style="z-index: 301; width: 450px; height: 325px;">
            <div id="selectManHead" class="datagrid-toolbar"><a class="easyui-linkbutton l-btn l-btn-plain"
                    iconcls="icon-ok" plain="true" onclick="checkSelectMan();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-ok l-btn-icon-left">选择</span></span></a><a
                    class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-reload" plain="true"
                    onclick="reload_data();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-reload l-btn-icon-left">刷新</span></span></a><a
                    class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-close" plain="true"
                    onclick="closeSelectMan();" id=""><span class="l-btn-left"><span
                            class="l-btn-text icon-close l-btn-icon-left">关闭</span></span></a></div>
            <div id="menu_tree" class="easyui-tree tree tree-lines" style="margin-top:35px;z-index: 300;"
                data-options="animate:true,lines:true,checkbox:true"></div>
        </div>
    </div>
    <div class="window-shadow" style="display: none; left: 433px; top: 25px;"></div>
    <div class="window-mask" style="width: 1316px; height: 403px; display: none;"></div>
</body>